<template>
	<view class="container">
		<u-navbar :border-bottom='false' title-bold="true" style="font-weight: 1200;"  title="银行卡">
		</u-navbar>
		<view class="tui-header">
			<view>
				<text class="tui-title">我的卡</text>
				<text class="tui-total">（共{{bankcardList.length}}张）</text>
			</view>
			<tui-tag plain type="danger" shape="circle" hover padding="12rpx 20rpx" @click="addBankCard">+ 添加银行卡</tui-tag>
		</view>
		<view class="tui-bankcard__list">
			<view v-for="(item,index) in bankcardList" :key="index" 
			class="tui-bankcard__item" :style='[cardStyleMap.get(item.bankType)]'>
				<view class="tui-card__info">
					<view class="tui-logo__box bankIcon" :class="['icon-'+item.bankType]" style="font-size: 80rpx;"></view>
					<view class="tui-name__box">
						<view class="tui-name">{{bankTypeMap.get(item.bankType)}}</view>
						<view class="tui-desc">{{cardTypeMap.get(item.cardType)}}</view>
					</view>
					<view class="tui-card__no">**** {{item.bankCard}}</view>
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
import {_bankTypeMap,_cardTypeMap,_cardStyleMap} from '@/pages/data/bank.js'
	export default {
		data() {
			return {
				bankcardList:[],
				bankTypeMap:[],
				cardTypeMap:[],
				cardStyleMap:[],
			}
		},
		onShow() {

			this.bankTypeMap=_bankTypeMap;
			this.cardTypeMap=_cardTypeMap;
			this.cardStyleMap=_cardStyleMap;
			this.$u.api.getBankCardList().then(res=>{
				this.bankcardList=res
			})
		},
		methods: {
			addBankCard() {
               uni.navigateTo({
               	url: "/pages/bankCard/addBankCard"
               });
			}
		}
	}
</script>

<style>
	.container {
		width: 100%;
		padding: 0 40rpx 40rpx;
		box-sizing: border-box;
	}

	.tui-header {
		width: 100%;
		padding: 36rpx 0;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.tui-title {
		font-size: 30rpx;
		font-weight: bold;
	}

	.tui-total {
		font-size: 24rpx;
		color: #999;
	}

	.tui-bankcard__item {
		width: 100%;
		height: 240rpx;
		padding: 30rpx;
		box-sizing: border-box;
		border-radius: 16rpx;
		margin-bottom: 20rpx;
	}

	.tui-logo__box {
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
		background-color: #fff;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-right: 20rpx;
	}

	.tui-logo {
		width: 52rpx;
		height: 52rpx;
	}

	.tui-card__info {
		display: flex;
		align-items: center;
		color: #fff;
	}

	.tui-name {
		font-size: 30rpx;
		font-weight: 500;
	}

	.tui-desc {
		font-size: 24rpx;
		opacity: 0.7;
	}

	.tui-card__no {
		margin-left: auto;
	}


</style>
